import { get, post } from '/@/api/http'
const serverContextPath = '/designer-server'

//SysFormDesigner分页接口
export interface SysFormDesigner {
  records: {
    id: string;
    version: number;
    formCode: string;
    formName: string;
    formType: string;
    remark: string;
    formDesJson: string;
  }[];
  pageNumber: number;
  pageSize: number;
  totalPage: number;
  totalRow: number;
  optimizeCountQuery: boolean;
}

export const developApi = {
  /**
   * 分页查询表单设计
   * @param data 
   * @returns 
   */
  querySysFormDesignerListPage: (data: any) => {
    return post<SysFormDesigner>({
      url: serverContextPath + '/sysFormDesigner/page',
      data: data,
    })
  },
  /**
   * 删除表单设计记录
   * @param id 主键
   * @returns
   */
  deleteSysFormDesignerInfo: (id: string) => {
    return post({
      url: serverContextPath + '/sysFormDesigner/remove/' + id,
    })
  },
  /**
   * 新增表单设计记录
   * @param dataForm 参数
   * @returns
   */
  saveSysFormDesignerInfo: (dataForm: any) => {
    return post({
      url: serverContextPath + '/sysFormDesigner/save',
      data: dataForm,
    })
  },
  /**
   * 修改表单设计记录
   * @param dataForm 参数
   * @returns
   */
  updateSysFormDesignerInfo: (dataForm: any) => {
    return post({
      url: serverContextPath + '/sysFormDesigner/update',
      data: dataForm,
    })
  },

  /**
   * 保存并发布
   * @param dataForm 参数
   * @returns
   */
  releaseSysFormDesignerInfo: (dataForm: any) => {
    return post({
      url: serverContextPath + '/sysFormDesigner/release',
      data: dataForm,
    })
  },

  /**
   * 根据名称查询表单
   * @param name 	
   */
  getFormDesignerByNameLike: (name: string) => {
    return post({
      url: serverContextPath + '/sysFormDesigner/getFormDesignerByNameLike',
      data: {
        'formName': name,
      }
    })
  },

  /**
   * 分页查询
   * @param data {
        page: pagination.page,
        pageSize: pagination.pageSize,
        param: {...},
      }
    * @returns
    */
  querySysBusinessCommonListPage: (data: any) => {
    return post({
      url: serverContextPath + '/sysBusinessCommon/page',
      data: data,
    })
  },
  /**
   * 新增
   * @param dataForm 参数
   * @returns
   */
  saveSysBusinessCommonInfo: (dataForm: any) => {
    return post({
      url: serverContextPath + '/sysBusinessCommon/save',
      data: dataForm,
    })
  },
  /**
   * 修改
   * @param dataForm 参数
   * @returns
   */
  updateSysBusinessCommonInfo: (dataForm: any) => {
    return post({
      url: serverContextPath + '/sysBusinessCommon/update',
      data: dataForm,
    })
  },

  /**
   * 删除
   * @param id 主键
   * @returns
   */
  deleteSysBusinessCommonInfo: (id: string) => {
    return post({
      url: serverContextPath + '/sysBusinessCommon/remove/' + id,
    })
  },
  /**
   * 根据id加载业务数据
   * @param id 主键
   */
  getSysBusinessCommonInfoById: (id: string) => {
    return get({
      url: serverContextPath + '/sysBusinessCommon/getInfo/' + id
    })
  },
  /**
   * 分页查询
   * @param data {
      page: pagination.page,
      pageSize: pagination.pageSize,
      param: {...},
    }
  * @returns
  */
  querySysBusinessDesignerListPage: (data: any) => {
    return post({
      url: serverContextPath + '/sysBusinessDesigner/page',
      data: data,
    })
  },
  /**
   * 新增
   * @param dataForm 参数
   * @returns
   */
  saveSysBusinessDesignerInfo: (dataForm: any) => {
    return post({
      url: serverContextPath + '/sysBusinessDesigner/save',
      data: dataForm,
    })
  },
  /**
   * 修改
   * @param dataForm 参数
   * @returns
   */
  updateSysBusinessDesignerInfo: (dataForm: any) => {
    return post({
      url: serverContextPath + '/sysBusinessDesigner/update',
      data: dataForm,
    })
  },

  /**
   * 删除
   * @param id 主键
   * @returns
   */
  deleteSysBusinessDesignerInfo: (id: string) => {
    return post({
      url: serverContextPath + '/sysBusinessDesigner/remove/' + id,
    })
  },
  /**
   * 根据编号获取表单信息
   * @param designerCode 表单设计编号
   * @param type 类型：1-新增表单、2-修改表单、3-详情表单
   */
  getSysBusinessDesignerByCodeHasJson: (designerCode: string, type: string) => {
    return get({
      url: serverContextPath + '/sysBusinessDesigner/getSysBusinessDesignerByCodeHasJson/' + designerCode + '/' + type,
    })
  },
  /**
   * 通用表单提交
   * @param data 
   * @returns 
   */
  submitBusinessCommonAdd: (data: any) => {
    return post({
      url: serverContextPath + '/sysBusinessCommon/submitBusinessCommonAdd',
      data: data
    })
  },
  /**
   * 通用表单修改
   * @param data 
   * @returns 
   */
  submitBusinessCommonUpdate: (data: any) => {
    return post({
      url: serverContextPath + '/sysBusinessCommon/submitBusinessCommonUpdate',
      data: data
    })
  },
  /**
   * 分页查询
   * @param data {
      page: pagination.page,
      pageSize: pagination.pageSize,
      param: {...},
    }
  * @returns
  */
  sysmontagevform: (data: any) => {
    return post({
      url: serverContextPath + '/sysmontagevform/page',
      data: data,
    })
  },

  /**
   * 获取数据库字段类型
   * @param data {}
  * @returns
  */
  getDataBaseColumnTypes: () => {
    return get({
      url: serverContextPath + '/sysFormDesigner/getDataBaseColumnTypes'
    })
  },
  /**
   * 设置组件需要调用的外部接口
   * @param data {
   * 					id:,
   * 					apiList:[
   * 						apiType:服务类型1-内部、2-外部,
   * 						apiUrl:接口地址,
   * 						apiMethod:请求方法：get、post,
   * 						apiHeadScript:请求头脚本,
   * 						apiBodyScript:请求体脚本,
   * 				]}
   * @returns 
   */
  setDesignerApi: (data: any) => {
    return post({
      url: serverContextPath + '/sysFormDesigner/setDesignerApi',
      data: data
    })
  },
  /**
   * 获取流程目录树
   * @returns 
   */
  getWfProcessFolderTree: () => {
    return get({
      url: serverContextPath + '/sysBusinessDesigner/getWfProcessFolderTree'
    })
  },
  /**
  * 根据根据主键获取应用设计记录(详情接口)
  * @returns 
  */
  getInfo: (id: String | Number) => {
    return get({
      url: serverContextPath + `/sysBusinessDesigner/getInfo/${id}`
    })
  },
  /**
  * 根据设计编码获取表单
  * @returns 
  */
   getLatestInfoByCode: (code: String | Number) => {
    return get({
      url: serverContextPath + `/sysBusinessDesigner/getLatestInfoByCode/${code}`
    })
  },
}


